<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">

<h1>122312312</h1>

</div>
<script type="text/javascript" src="script/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="./script/plugins/vue/dist/vue.js"></script>
<script type="text/javascript" src="./script/plugins/axios/dist/axios.js"></script>
<script type="text/javascript" src="./commons/commons.js"></script>

<script type="text/javascript">
    new Vue({
        el:"#app",
        data:{

        },
        methods:{
            getAccessToken(code){
                this.$http.get("/wxuser/"+code).then(res=>{
                    res = res.data
                    if (res.success){
                        if (res.data.token){
                            localStorage.setItem("token",res.data.token)
                            localStorage.setItem("user",JSON.stringify(res.data.user))
                            location.href="/index.html"
                        }else {
                            //走绑定流程
                            location.href=res.data.page+"?code="+res.data.code;
                        }
                    }else{
                        alert(res.msg);
                    }

                })
            }
        },
        mounted() {
            var urldata = parseParamObj(location.href);
            let code =urldata.code;
            this.getAccessToken(code);
        }
    })
</script>

</body>
</html>